 /* jshint esversion: 6 */

import Vue from 'vue'
import router from './router'
import axios from './assets/lib/http'
import ElementUI from 'element-ui'
import Vant from 'vant'
 import 'vant/lib/index.css';
import NProgress from 'nprogress'
import VueAMap from 'vue-amap'
import './reset.css'
import 'element-ui/lib/theme-chalk/index.css'
import 'nprogress/nprogress.css'
import store from './store'
import App from './App.vue'
import 'echarts/extension/bmap/bmap';

 // import vConsole from "./assets/lib/vconsole";
Vue.use(ElementUI).use(axios);
Vue.use(Vant).use(axios);
 // Vue.use(vConsole);

 // 全局路由守卫
 router.beforeEach((to, from, next) => {
     const nextRoute = ['index','touristFlow','scenicSpotHeating','touristStyle','businessInterests','feedBack','changePassword'];
     let isLogin = localStorage.getItem('token');  // 是否登录
     // 未登录状态；当路由到nextRoute指定页时，跳转至login
     if (nextRoute.indexOf(to.name) >= 0) {
         if (!isLogin) {
             router.push({ name: 'login' })
         }
     }
     // 已登录状态；当路由到login时，跳转至home
     if (to.name === 'login') {
         if (isLogin) {
             router.push({ name: 'index' });
         }
     }
     next();
 })
//loading进度条
NProgress.inc(0.25);
NProgress.configure({ easing: 'ease-in', speed: 200, showSpinner: false, minimum: 0.1 });

//高德地图
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
  key: '77015ad31c76237ddc7de735afa2a230',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.Geolocation', 'AMap.Geocoder'],
  uiVersion: '1.0' // 版本号
});

router.afterEach((to,from) => {
  NProgress.done()
});

Vue.config.productionTip = false;
 new Vue({
     router,
     store,
     render: h => h(App)
 }).$mount('#app');

